/*

 MSpaceInvaders
 
 Copyright (c) 2007 Mary Jane Soft - Marlon J. Manrique
 	
 http://mjs.darkgreenmedia.com
 http://marlonj.darkgreenmedia.com
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 $Id: MSpaceInvaders.pde 272 2007-07-25 20:14:14Z marlonj $
 	
*/
 
import processing.phone.*;
import mjs.processing.mobile.m3d.*;

// 3D Engine
M3d m3d;

// Phone utils
Phone phone;

// Space Invader implementation
MSIGame game;


/**
 * Start the application.
 *
 * Create objects, load fonts
 */
void setup()
{
  // Create main objects  
  m3d = new M3d(this);  
  game = new MSIGame();
  phone = new Phone(this);
  
  // Font Settings
  textFont(loadFont());
  textAlign(CENTER);    
  
  // Add a softkey to allow start the game
  softkey("Start");
  
  // Show the game information
  showInfoScreen();  
}

/**
 * Draw all the components
 */
void draw()
{  
  // Draw the game components
  game.draw();
}

void keyPressed()
{
  game.keyPressed();
}

void keyReleased()
{
  game.keyReleased();
}

/**
 * Check the sofkey
 *
 * @param label Label of the softkey pressed
 */
void softkeyPressed(String label)
{
  // If the keys is start
  // Remove the softkey and start the game
  if(label.equals("Start"))
  {
    softkey("");    
    game.startGame();
  }
}

/**
 * Show the game information
 */
void showInfoScreen()
{
  // Clear the screen and show game information
  background(0);
  text("MSpaceInvaders",width/2,height/2);
  text("http://trak.to/marlonj",width/2,height/2 + 20);
}
